package protocol.JT808_2019;

import java.util.HashMap;

public class Handle808_2019JT85 implements IHandle808_2019JT {
    @Override
    public String handle(JT808_2019Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x00:
                return handle8500(cmd);
            default:
                return "808-2019:未匹配的命令字"+(cmd.readOrder()+","+cmd.readSubOrder());
        }
    }

    private String handle8500(JT808_2019Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:车辆控制");
        builder.append("\r\n");

        int size = cmd.readWORD();

        for (int i = 0; i < size; i++) {
            final int type = cmd.readWORD();
            int order = cmd.readInt(1);
            switch (type){
                case 1:
                    builder.append("车门："+(order == 0?"车门锁闭":"车门开启"));
                    break;
                default:
                    builder.append("未定义("+type+"):"+order);
                    break;
            }
            builder.append("\r\n");
        }


        return builder.toString();
    }

}
